package com.lin.chapter5;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.charset.Charset;

public class ByteBufReadWrite {
	public static void main(String[] args) {
		Charset charset = Charset.forName("UTF-8");
		ByteBuf byteBuf = Unpooled.copiedBuffer("Netty in Action rocks!", charset);
		System.out.println((char)byteBuf.getByte(0));
		int readerIndex = byteBuf.readerIndex();
		int writerIndex = byteBuf.writerIndex();
		byteBuf.writeByte((byte)'?');
		assert readerIndex == byteBuf.readerIndex();
		assert writerIndex != byteBuf.writerIndex();
	}
}
